﻿using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Storage;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;


namespace Adi_Game
{
    class Map
    {
        String filename;
        public char[] tiles;
        int mapSize;

        public Map(string file)
        {
            filename = file;
            ReadFile();
        }

        public void ReadFile()
        {
         
            StreamReader reader = new StreamReader(filename);
            int width;
            string lineFromFile = reader.ReadLine();
            width = lineFromFile.Length;

            tiles = new char[width];

            for (int i = 0; i < width; i++)
            {
                char c = lineFromFile[i];
                tiles[i] = c;
            }
            mapSize = width;
        }


        public void DrawTiles(SpriteBatch sprite, Texture2D tile)
        {

            for (int i = 0; i < mapSize; i++)
            {

                if (tiles[i] != '-')
                {
                    sprite.Draw(tile, new Rectangle(64*i, 36*19, 64, 36), Color.White);
                }
            }
        }
    }
}
